Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
plugin-error
Advanced tools
The plugin-error npm package is designed to simplify error handling in plugin development, particularly for Gulp plugins. It provides a consistent way to create and manage errors, making it easier to debug and handle errors in a standardized manner.
Creating a PluginError
This feature allows you to create a new PluginError instance. The first argument is the plugin name, and the second argument is the error message. This helps in identifying which plugin caused the error.
const PluginError = require('plugin-error');
const err = new PluginError('MyPlugin', 'Something went wrong!');
console.error(err.toString());
Handling Error Options
This feature allows you to pass an options object to the PluginError constructor. The options can include properties like 'message' and 'showStack' to customize the error output.
const PluginError = require('plugin-error');
const err = new PluginError('MyPlugin', {
message: 'Something went wrong!',
showStack: true
});
console.error(err.toString());
Using Error Codes
This feature allows you to specify an error code, which can be useful for programmatically identifying different types of errors.
const PluginError = require('plugin-error');
const err = new PluginError('MyPlugin', {
message: 'Something went wrong!',
code: 'EPLUGIN'
});
console.error(err.toString());
The fancy-log package is used for logging messages in a more readable format. While it doesn't specifically handle errors, it can be used alongside plugin-error to log error messages in a more user-friendly way.
The gulplog package is a logging utility specifically designed for Gulp. It provides a way to log messages at different levels (info, warn, error). While it doesn't create error objects like plugin-error, it can be used to log errors created by plugin-error.
The chalk package is used for styling terminal string output. It can be used in conjunction with plugin-error to colorize error messages, making them easier to read and debug.
Error handling for Vinyl plugins.
var PluginError = require('plugin-error');
var err = new PluginError('test', {
message: 'something broke'
});
var err = new PluginError({
plugin: 'test',
message: 'something broke'
});
var err = new PluginError('test', 'something broke');
var err = new PluginError('test', 'something broke', { showStack: true });
var existingError = new Error('OMG');
var err = new PluginError('test', existingError, { showStack: true });
new PluginError(pluginName, message[, options])
Error constructor that takes:
pluginName
- a String
that should be the module name of your pluginmessage
- a String
message or an existing Error
objectoptions
- an Object
of your optionsBehavior:
options.showStack
to true if you think the stack is important for your error.err.toString()
, but may be omitted by including { showProperties: false }
in the options.MIT
FAQs
Error handling for Vinyl plugins.
We found that plugin-error demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.